package com.shangyueshang.controller.finance;

import com.shangyueshang.model.GoodsAdvertiseFee;
import com.shangyueshang.request.PageReq;
import com.shangyueshang.response.HttpResult;
import com.shangyueshang.response.PageResult;
import com.shangyueshang.service.GoodsAdvertiseFeeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: JokeyZheng
 * @email: zhengjingfeng@ruqimobility.com
 * @created: 2023/5/16 15:14
 * @version: v1.0.0
 */
@RestController
@RequestMapping("/advertise")
public class AdvertiseCostController {

    @Resource
    private GoodsAdvertiseFeeService goodsAdvertiseFeeService;

    /**
     * 分页查询
     *
     * @param pageReq
     * @return
     */
    @PostMapping("/findPage")
    @PreAuthorize("hasAuthority('finance:advertise:view')")
    public HttpResult<PageResult<GoodsAdvertiseFee>> findPage(@RequestBody PageReq pageReq) {
        return HttpResult.ok(goodsAdvertiseFeeService.findPage(pageReq));
    }

    /**
     * 导出广告数据
     *
     * @param pageReq
     * @return
     */
    @PostMapping("/fee/export")
    @PreAuthorize("hasAuthority('finance:advertise:fee:export')")
    public void export(@RequestBody PageReq pageReq, HttpServletResponse response) {
        goodsAdvertiseFeeService.export(pageReq, response);
    }
}
